package route

import (
	"github.com/gin-gonic/gin"
	"socket/controller"
	ws "socket/controller/socket"
	"socket/controller/user"
	"socket/middleware"
)

func CollectRoute(r *gin.Engine) *gin.Engine {
	//r.Use(middleware.LoggerToFile())

	commonRoutes := r.Group("/api/common") //公共
	commonController := controller.NewCommonController()
	commonRoutes.GET("/oss", commonController.Oss)
	commonRoutes.POST("/local_file", commonController.LocalFile)
	r.POST("/api/upload_file", controller.UploadFile)
	commonRoutes.GET("/sendSms", commonController.SendSms)
	commonRoutes.GET("/sendmail", commonController.SendMail)

	r.GET("/api/socket", ws.Socket)

	//用户注册登录
	r.POST("/api/user/reg", user.Reg)
	r.POST("/api/user/login", user.Login)

	r.Use(middleware.AuthMiddle())

	r.GET("/api/user/info", user.Info)
	r.GET("/api/user/list", user.List)
	r.GET("/api/user/list/:sn", user.Show)

	return r
}
